const http = require('http');
const fs = require('fs');

const server = http.createServer();
let wwwDir = 'F:/www';
server.on('request',function (req,res) {
    let url = req.url
    let filePath = 'index.html'
    if (url !== '/') {
        filePath = url
    }

    fs.readFile(wwwDir + filePath, function (err,data) {
        if (err) {
            res.end('404 Not Found.')
        }
        res.end(data);
    });


});

server.listen('9000',function () {
    console.log('server is running on port 9000.');
});